package com.module.base.utils;

import android.content.Context;

import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.module.base.R;
import com.module.base.widget.decoration.ItemDecoration;
import com.module.base.widget.layoutmanager.NoScrollLayoutManager;

import skin.support.content.res.SkinCompatResources;

/**
 * @author bsnl_yanxuwen
 * @date 2021/1/21 16:26
 * Description :
 */
public class RecycleViewUtil {

    public static LinearLayoutManager getLinear(Context context) {
        return new NoScrollLayoutManager(context);
    }

    public static GridLayoutManager getGrid(Context context, int size) {
        return new GridLayoutManager(context, size);
    }

    public static ItemDecoration divider(Context context) {
        return divider(context, 1);
    }

    public static ItemDecoration divider(Context context, int dividerWidth) {
        return divider(context, R.color.transparent, dividerWidth);
    }

    public static ItemDecoration divider(Context context, @ColorRes int id, int dividerWidth) {
        return divider(context, id, dividerWidth, 0);
    }

    public static ItemDecoration divider(Context context, @ColorRes int id, int dividerWidth, int dividerMargin) {
        return dividerColor(context, SkinCompatResources.getColor(context, id), dividerWidth, dividerMargin);
    }

    public static ItemDecoration dividerColor(Context context, @ColorInt int color, int dividerWidth, int dividerMargin) {
        ItemDecoration divider = new ItemDecoration(context, color, dividerWidth, dividerMargin);
        return divider;
    }
}
